// import cookies from 'weapp-cookie'

function request(data) {
	// console.log(cookies.get('newly_token', 'newly_token'))
	const baseURL = 'http://192.168.1.42:9090'
	// const baseURL = 'http://192.168.1.57:3300'
	return new Promise((resolve, reject) => {
		uni.request({
			url: baseURL + data.url,
			method: data.method ? data.method : 'GET',
			data: data.data,
			timeout: 5000,
			header: data.header ? data.header : {
				'Authorization': uni.getStorageSync(
					'token'),
				// 'Content-Type': 'application/x-www-form-urlencoded'
				'content-type': 'application/x-www-form-urlencoded'
			},
			success(res) {
				console.log(res)
				resolve(res.data)
			},
			fail(err) {
				reject(err)
			}
		});
	})
}

export default request